package com.smm.web.vmc.api;


import com.smm.web.vmc.domain.Receipt;
import com.smm.web.vmc.dto.JsonReturn;
import com.smm.web.vmc.service.CameraService;
import com.smm.web.vmc.service.ReceiptService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 仓单信息
 */
@Controller
@RequestMapping(value = "/api/rep",method = RequestMethod.POST)
public class RepApi {

    @Resource
    private ReceiptService receiptService;

    @Resource
    private CameraService cameraService;


    @RequestMapping({"/info.do"})
    @ResponseBody
    public JsonReturn info(String no) {

        Receipt receipt = this.receiptService.getOneById(no);

        List relationCameraList = this.cameraService.getAllByReceipt(no);

        Map<String ,Object> result = new HashMap<>();

        result.put("receipt",receipt);

        result.put("cameraList",relationCameraList);

        return new JsonReturn(1,"success",result);

    }
}
